﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using OgilvyOne.BLL;
using OgilvyOne.Model;

using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Model;
using System.Collections.Generic;
using ECCIT;
public partial class admin_UKNOW_element_element_comment_list :  AdminBasePage
{
    private const string VIEWSTATE_COLUMN_ID = "columnid";
    private const string VIEWSTATE_LAYER_ID = "layerid";
    private const string VIEWSTATE_WARMUP_ID = "WarmupsID";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ViewState[VIEWSTATE_COLUMN_ID] = int.Parse(Request.Params[VIEWSTATE_COLUMN_ID]);
            ViewState[VIEWSTATE_LAYER_ID] = Request.Params[VIEWSTATE_LAYER_ID];
            ViewState[VIEWSTATE_WARMUP_ID] = Request.Params[VIEWSTATE_WARMUP_ID]; 
            this.headers.Text = "作品评论列表";
            Grid_viewBild();
        }
    }
    private void Grid_viewBild()
    {
        //根据作品的ID(部分活动)获取该作品的所有的评论的所有信息

        int Warmup_ID = int.Parse(ViewState[VIEWSTATE_WARMUP_ID].ToString());
        IList<WarmupCommentModel> WarmupComments = new WarmupsCommentBLL(LangID).SelectCommentByID(Warmup_ID);
        GridView1.DataSource = WarmupComments;
        GridView1.PageSize = 10;
        GridView1.DataBind();
        this.pagehtml.Text = getPageHtml(GridView1.PageCount, GridView1.PageIndex + 1, WarmupComments.Count);
    }
    protected void Pubone_click(object sender, EventArgs e)
    {
        //修改单个评论的发布状态
        int wid = int.Parse(((LinkButton)sender).CommandArgument);
        new WarmupsCommentBLL(LangID).modPubOne(wid);
        Grid_viewBild();
    }
    protected void Del_click(object sender, EventArgs e)
    {
        int wcid = int.Parse(((LinkButton)sender).CommandArgument);
        ResultInfo res = new WarmupsCommentBLL(LangID).delWarmupComment(wcid);
        if (res.Result)
        {
            Response.Write("<script>alert('" + res.Message + "')</script>");
        }
        else
        {
            Response.Write(res.Message);
        }

        //删除作品的数据记录
        Grid_viewBild();
    }
    protected void Return_click(object sender, EventArgs e)
    {
       
        Response.Redirect(string.Format("element_list.aspx?{0}={1}&{2}={3}&{4}={5}", VIEWSTATE_COLUMN_ID, ViewState[VIEWSTATE_COLUMN_ID], VIEWSTATE_LAYER_ID, ViewState[VIEWSTATE_LAYER_ID] , "langID", this.LangID));
       
    }
}